package com.hsl.study.filter;


import jakarta.servlet.*;
import jakarta.servlet.annotation.WebFilter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * @Author: hsl
 * @CreateTime: 2025-02-14  20:05
 * 过滤所有请求
 */
@Component
@Slf4j
@WebFilter("/*")
public class DemoFilter implements Filter {

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        Filter.super.init(filterConfig);
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        log.info("Filter 进入");
        filterChain.doFilter(servletRequest, servletResponse);
        log.info("Filter 退出");
    }

    @Override
    public void destroy() {
        Filter.super.destroy();
    }
}
